package com.maple.exclusivesport;

import android.Manifest;
import android.content.ContentValues;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.design.widget.TabLayout;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;

import com.maple.exclusivesport.ui.main.MyFragmentPagerAdapter;
import com.maple.exclusivesport.ui.main.PlaceholderFragment;
import com.maple.exclusivesport.ui.main.Record2PlaceholderFragment;
import com.maple.exclusivesport.ui.main.RecordPlaceholderFragment;
import com.maple.exclusivesport.ui.main.SectionsPagerAdapter;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        TTSUtils.getSingleton(this);
        Fragment[] fragments=new Fragment[]{PlaceholderFragment.newInstance(1), RecordPlaceholderFragment.newInstance(1), Record2PlaceholderFragment.newInstance(1)};
        MyFragmentPagerAdapter myFragmentPagerAdapter=new MyFragmentPagerAdapter(this,getSupportFragmentManager(),fragments);
        SectionsPagerAdapter sectionsPagerAdapter = new SectionsPagerAdapter(this, getSupportFragmentManager());
        ViewPager viewPager = findViewById(R.id.view_pager);
        viewPager.setAdapter(myFragmentPagerAdapter);
        TabLayout tabs = findViewById(R.id.tabs);
        tabs.setupWithViewPager(viewPager);
        FloatingActionButton fab = findViewById(R.id.fab);


        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(MainActivity.this,JournalActivity.class));
            }
        });
        ActivityCompat.requestPermissions(this,
                new String[]{
                        Manifest.permission.CAMERA,
                        Manifest.permission.WRITE_EXTERNAL_STORAGE,
                        Manifest.permission.READ_EXTERNAL_STORAGE}, 1);
    }
}